Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Nack interceptors #4

Merged
merged 1 commit into from
Dec 14, 2020
Merged

Added Nack interceptors #4

merged 1 commit into from
Dec 14, 2020

Conversation

masterada
Copy link
Contributor

@masterada masterada commented Nov 27, 2020

Ref: #3

@codecov
Copy link

codecov bot commented Nov 27, 2020

Codecov Report

Merging #4 (07afb0f) into master (f6577b2) will increase coverage by 16.64%.
The diff coverage is 81.13%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master       #4       +/-   ##
===========================================
+ Coverage   54.61%   71.26%   +16.64%     
===========================================
  Files           7       13        +6     
  Lines         130      341      +211     
===========================================
+ Hits           71      243      +172     
- Misses         48       70       +22     
- Partials       11       28       +17     
Flag Coverage Δ
go 71.26% <81.13%> (+16.64%) ⬆️
wasm 71.26% <81.13%> (+16.64%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pkg/nack/responder_interceptor.go 65.78% <65.78%> (ø)
pkg/nack/nack.go 66.66% <66.66%> (ø)
pkg/nack/generator_interceptor.go 75.40% <75.40%> (ø)
pkg/nack/send_buffer.go 83.87% <83.87%> (ø)
pkg/nack/receive_log.go 90.16% <90.16%> (ø)
pkg/nack/generator_option.go 100.00% <100.00%> (ø)
pkg/nack/responder_option.go 100.00% <100.00%> (ø)
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f6577b2...07afb0f. Read the comment docs.

.gitignore Outdated Show resolved Hide resolved
nack/receive_log.go Outdated Show resolved Hide resolved
test/stream.go Outdated Show resolved Hide resolved
@Sean-Der

This comment has been minimized.

@Sean-Der

This comment has been minimized.

nack/send_buffer.go Outdated Show resolved Hide resolved
@Sean-Der
Copy link
Member

@masterada rebased off of master, reviewing again!

@Sean-Der
Copy link
Member

Sean-Der commented Nov 29, 2020

@masterada this is really great, approved! I especially love how readable the tests are. I think the Public API is rock solid, and the internals are good. Lots of WaitGroup, Mutex and Channels make for challenging code, but that is the problem space!

If you could squash this down into one commit, or 3 Stream Test Utils, Sender and Receiver I would really appreciate it. It really helps me later when I have to read code and debug/update stuff :)

I think if we have this + Receiver/Sender reports and enable them by default that would make a perfect v3.0.0

@at-wat would love if you could review/see if this captures the spirit? This will be a blueprint for lots of future work, so would love to have it.

@@ -0,0 +1,161 @@
package test
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like mockstream may be better package naming.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@at-wat what do you think of the name now? Feel free to edit the branch directly!

nack/generator_interceptor.go Outdated Show resolved Hide resolved
nack/receive_log_test.go Outdated Show resolved Hide resolved
nack/responder_interceptor.go Outdated Show resolved Hide resolved
nack/responder_interceptor.go Outdated Show resolved Hide resolved
nack/responder_option.go Outdated Show resolved Hide resolved
@Sean-Der
Copy link
Member

Sean-Der commented Dec 3, 2020

@masterada If you don't have the availability I am happy to pull in the suggested changes :)

No rush, I just don't want to overload you! What do you think of having pion/webrtc go out with Receiver Reports + NACK by default? You think good/bad idea.

Or should we push v3.0.0 with no interceptors, and do a minor release with them?

@masterada
Copy link
Contributor Author

@Sean-Der sorry, I just started work at a new place and it comsumes more energy than I expected. Not sure when I could finish these comments, probably only next week (my weekend is kinda budy too). Please if you have the time feel free to finish this up. Also there is a TODO to move sequence numbers -> nack pair conversion to rtcp packet, because the other way is alread there. It's not really important, can be done sometime later too.

I replied to 2 comments @at-wat , other than that I agree with you in everything.

What do you think of having pion/webrtc go out with Receiver Reports + NACK by default? You think good/bad idea.

I think it would be nice to add at least 1 interceptor to 3.0.0, so we can be sure the interceptor integration works, and also create the RegisterDefaultInterceptors method that actually does something. RR/SR and TCC would be nice too but they can come at 3.1 too or something.

Also note that in order for nack.GeneratorInterceptor to work, you need to call s.SetSRTPReplayProtectionWindow(AT_LEAST_NACK_SIZE), see: https://github.com/pion/webrtc/pull/1549/files#diff-6e2e56e295d82766f7fdce880ab65f299e92aede458043e232610c9fe9166e03R58

Maybe a higher default value for that could work? I think google uses 10000 for the replay protection window size, not sure though, their c code is very hard to follow.

}

return &ReceiveLog{
packets: make([]uint64, size/64),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be an interface: if my application is already logging packets for some other reason, then I should be able to pass my receive log to the interceptor rather than keeping yet another copy of the log.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Buffers should not be shared. Here is my reasoning:

receive_log:
Receive log stores only the fact that the packet arrived. That means it uses 1 bit per packet, for 8192 pacekts, it uses 1024bytes. If I remember correctly the mtu is about 1.5 kB, so that means the whole receive log is smaller than a single video packet.

send_buffer:
This is more tricky, because it stores every packet. If you have multiple outgoing stream, like in the case of a SFU, it will store the packets for every stream. But:

  • packet payload is a slice, meaning the underlying data is not copied, it's only stored once
  • header will be mostly different for every sfu client, because payload type, extensions, ssrc, etc. can differ
    If reusing a buffer, you would have to fix all headers every time you send out a packet. This might work for an sfu server, but there are more complicated use cases than that.
  • in a centralized buffer it's much harder to configure when a packet can be discarded (eg: in the future the nack sender interceptor can listen to tcc packets as well, allowing it to drop packets based on it)

The final reason I'm against a single shared buffer is jitter handling. You might want to use the same stream with and without a jitter buffer at the same time. We have an aplication that saves a stream to a webm file on disk, but also forwards the stream to a single viewer. We then proxy the tcc packets from the viewer back to the broadcaster. In this case, the file save part needs a jitter buffer, but the proxy part does not, because the jitter buffer messes with the packet delays from the viewer's perspective, and messes up the whole tcc.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, yes, I meant the send buffer.

In this comment, I'm not arguing against or in favour of a shared buffer. I'm merely arguing that the send buffer should be an interface that the user implements. Your current implementation is probably fine as the default, but the user should be able to provide a different implementation for the buffer.

nack/receiver_interceptor.go Outdated Show resolved Hide resolved
nack/receiver_interceptor.go Outdated Show resolved Hide resolved
nack/receiver_interceptor.go Outdated Show resolved Hide resolved
@Sean-Der
Copy link
Member

Sean-Der commented Dec 4, 2020

@masterada congrats on the new job! No worries at all, you have done some amazing work here. I am more then happy to finish out the rest :)

@Sean-Der
Copy link
Member

Sean-Der commented Dec 4, 2020

@masterada @at-wat mind giving it another look? I went through and address everything in your reviews.

thanks!

@masterada
Copy link
Contributor Author

LGTM, but i think this should wait until the raw read and attributes changes are in.

* ResponderInterceptor which responds to NACK Requests
* GeneratorInterceptor which generates NACK Requests
@Sean-Der Sean-Der merged commit 76181b1 into master Dec 14, 2020
@Sean-Der Sean-Der deleted the nack branch December 14, 2020 06:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants